set trace off
clear all


set matsize 10000
set maxvar 32500


use moments_0_0,clear
drop if cohot == 1963 & cohos == 1963
append using moments_1_1 
append using moments_2_2





forv b=0(1)2 {
	forv c = 1936(3)1984 {
		capture mkmat dev_`b'`b'_`c'`c'_* if bobt==`b' & bobs==`b' & cohot==`c' & cohos==`c', mat(fm_`b'`b'_`c'`c')
		capture mat fminv_`b'`b'_`c'`c'=syminv(fm_`b'`b'_`c'`c')
		capture drop dev_`b'`b'_`c'`c'_*
	}  
}




append using moments_0_1

		local cotd = 1936
		local cotu = 1966 

		local cosd = 1957
		local cosu = 1984 

		forv cot = `cotd'(3)`cotu' {
			forv cos = `cosd'(3)`cosu' {
				capture mkmat dev_01_`cot'`cos'_* if bobt==0 & bobs==1 & cohot==`cot' & cohos==`cos', mat(fm_01_`cot'`cos')
				capture mat fminv_01_`cot'`cos'=syminv(fm_01_`cot'`cos')
				capture drop dev_01_`cot'`cos'_*
			}			
		}
cap drop dev*	
append using moments_0_2

		local cotd = 1936
		local cotu = 1966 

		local cosd = 1960
		local cosu = 1984  
		
		forv cot = `cotd'(3)`cotu' {
			forv cos = `cosd'(3)`cosu' {
				capture mkmat dev_02_`cot'`cos'_* if bobt==0 & bobs==2 & cohot==`cot' & cohos==`cos', mat(fm_02_`cot'`cos')
				capture mat fminv_02_`cot'`cos'=syminv(fm_02_`cot'`cos')
				capture drop dev_02_`cot'`cos'_*
			}			
		}

		
cap drop dev*
append using moments_1_2
 

		local cotd = 1957
		local cotu = 1984  
		
		
		local cosd = 1960
		local cosu = 1984  
		
		forv cot = `cotd'(3)`cotu' {
			forv cos = `cosd'(3)`cosu' {
				capture mkmat dev_12_`cot'`cos'_* if bobt==1 & bobs==2 & cohot==`cot' & cohos==`cos', mat(fm_12_`cot'`cos')
				capture mat fminv_12_`cot'`cos'=syminv(fm_12_`cot'`cos')
				capture drop dev_12_`cot'`cos'_*
			}			
		}

cap drop dev*	

forv i=0(1)34 { 
	cap drop dr`i' dc`i'
	local y= `i' + 1980
	ge dr`i' = yt==`y'
	ge dc`i' = ys==`y'	
}

mvencode dco*, mv(0) o
renpfix dco19 dco

